package com.morty.config;

import lombok.extern.log4j.Log4j2;
import org.elasticsearch.client.HttpAsyncResponseConsumerFactory;
import org.elasticsearch.client.RequestOptions;
import org.springframework.stereotype.Component;

/**
 * @Project:
 * @Description:
 */
@Log4j2
@Component
public class CommonOptions {
    public static final RequestOptions COMMON_OPTIONS;
    static {

        RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder();
        log.info("---------ES初始化配置--------");
        // 默认缓存限制为100MB，此处修改为30MB。
        builder.setHttpAsyncResponseConsumerFactory(
                new HttpAsyncResponseConsumerFactory
                        .HeapBufferedResponseConsumerFactory(30 * 1024 * 1024));
        COMMON_OPTIONS = builder.build();
    }
}
